#ifndef BOSS_Afterburner_Globals_Functions_String_H
#define BOSS_Afterburner_Globals_Functions_String_H

#include "TString.h"
#include "TTree.h"
#include <string>

namespace BOSS_Afterburner
{
  /// @addtogroup Afterburner_functions
  /// @{
  /// Namespace containing functions for `string` manipulation.
  /// @author  Remco de Boer 雷穆克 (r.e.deboer@students.uu.nl or remco.de.boer@ihep.ac.cn)
  /// @date    November 20th, 2018
  namespace String
  {
    std::string& Trim(std::string& input);
    std::string& Trim(std::string& input, char c);
    TString&     Trim(TString& input);
    TString&     Trim(TString& input, char c);
    const bool   IsComment(std::string line);
    const bool   IsComment(const TString& line);
    TString      NoExtension(TString path);
    TString      NoMainDir(TString path);
    template <typename TYPE>
    inline std::string CommaFormattedString(TYPE number);
  } // namespace String
  /// @}
} // namespace BOSS_Afterburner

/// Create a `string` from a number that has a number between each 3 digits.
template <typename TYPE>
inline std::string BOSS_Afterburner::String::CommaFormattedString(TYPE number)
{
  int num = number;
  std::string output         = std::to_string(num);
  int         insertPosition = output.length() - 3;
  while(insertPosition > 0)
  {
    output.insert(insertPosition, ",");
    insertPosition -= 3;
  }
  return output;
}

#endif